home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / TURB_VIS / MISC / MISC.DOC < prev    next >
Text File  |  1990-12-17  |  9KB  |  291 lines

  1.  
  2.                                 MISC.PAS
  3.                      A Turbo Vision Object Library
  4.  
  5.                              By  Devin Cook
  6.                                MSD - 1990
  7.  
  8. I haven't been exactly overwhelmed by the amount of Turbo Vision objects shared
  9. by TP users, so I thought I would thow my hat into the ring and spread a few
  10. objects I have developed around.
  11.  
  12. I am not an expert in Turbo Vision ( who can be in 3 weeks? ), or in OOP, so I
  13. have probably broken quite a few rules, but you might get some ideas from the
  14. work I have done.
  15.  
  16. This unit has some of the my more mainstream objects included.  I have a few
  17. other, less general objects which I may spread around later.
  18.  
  19. These objects have not been used enough to verify they are 100% bug free, so
  20. if you find any problems, or have any comments, please send me some Email
  21. ( D.Cook on Genie ).
  22.  
  23.                                 OBJECTS:
  24.  
  25. TDateView      -    A date text box, much like TClockView in TVDemos.
  26.  
  27. TPushButton    -    A descendend of TButton, with "feel" for keyboard users.
  28.  
  29. TNum_Box       -    A number only input box with an adjustable number of digits
  30.                     before and after the decimal point, along with selectable
  31.                     negative number acceptance.
  32.  
  33. TLinked_Dialog -    A descendent of TDialog which allows you to set "Links"
  34.                     between items ( i.e. item selection through cursor keys ).
  35.  
  36. Also, FormatDate, a function used by TDateView is provided.
  37.  
  38.  
  39.                             ╔═════════════╗
  40.                             ║  TDateView  ║
  41.                             ╚═════════════╝
  42.  
  43.  
  44. TDateView is almost identicle to TClockView ( in TVDemos - Gadget.Pas ).
  45.  
  46. INITIALIZATION:
  47.  
  48. TDateView is initialized by sending TDateView a TRect giving it's location.
  49.  
  50. USAGE:
  51.  
  52. Once TDateView is initialized, an occasional call to TDateView.Update keeps
  53. the displayed date current.
  54.  
  55. Example:
  56.  
  57.   Var TR    : TRect ;
  58.       DateV : TDateView ;
  59.   Begin
  60.       TR.Assign( 60 , 0 , 78 , 1 );
  61.       DateV.Init( TR );
  62.       DateV.Update ;
  63.   End;
  64.  
  65.  
  66.  
  67.                            ╔═══════════════╗
  68.                            ║  TPushButton  ║
  69.                            ╚═══════════════╝
  70.  
  71.  
  72. TPushButton is identicle to TButton in every way except that when it is
  73. "pressed", it actually draws itself pressed.
  74.  
  75. This gives visual feedback to those using non-mouse systems.
  76.  
  77. The delay values in TPushButton.Press may need to be altered to adjust the
  78. "feel".
  79.  
  80.                              ╔════════════╗
  81.                              ║  TNum_Box  ║
  82.                              ╚════════════╝
  83.  
  84.  
  85. TNum_Box is a numerical entry box with definable precision.
  86.  
  87. INITIALIZATION:
  88.  
  89. TNum_Box is initialized by sending TNum_Box.Init:
  90.         Location                            : TPoint
  91.         Max Digits before the decimal point : Integer
  92.         Max Digits after the decimal point  : Integer
  93.         Negative Numbers allowed flag       : Boolean
  94.         Default Value                       : Extended
  95.  
  96. If the digits after the decimal point = 0, no decimal point is displayed
  97. ( or excepted ).
  98.  
  99. If negative numbers are allowed, one extra space is reserved for a negative
  100. sign.  No digits can be entered in this spot.
  101.  
  102. Only Backspace is used to edit the numberical field.
  103.  
  104. USAGE:
  105.  
  106. The value of the input box can be read directly from TNum_Box.Curr_Val.
  107.  
  108. This value may not be up to date if editing is still taking place, or no
  109. data has been entered.  To ensure a correct reading, a call to
  110. TNum_Box.Update_Value is recommended.
  111.  
  112. After initilization, the box is displayed with blanks for the number of digits.
  113. If you wish to display the default value instead, use TNum_Box.Update_Value.
  114.  
  115. Example:
  116.  
  117.   Var TP        : TPoint ;
  118.       Int_Box1  : TNum_Box ;
  119.       Int_Box2  : TNum_Box ;
  120.       Flt_Box1  : TNum_Box ;
  121.   Begin
  122.       Tp.X := 10 ;
  123.       Tp.Y := 5 ;
  124.  
  125.       (* Define a box at 10,5 with 3 digits, no decimals, no negatives and a
  126.          default of 0 *)
  127.  
  128.       Int_Box1.Init( TP , 3 , 0 , False , 0 )
  129.  
  130.       TP.X := 15 ;
  131.  
  132.       (* Define a box at 10,15 with 5 digits, no decimals, negatives and a
  133.          default of 1.  Then, update the box displaying the default *)
  134.  
  135.       Int_Box2.Init( TP , 5 , 0 , True , 1 )
  136.       Int_Box2.Update_Value ;
  137.  
  138.       TP.X := 25 ;
  139.  
  140.       (* Define a box at 10,25 with 5 digits, 2 decimal places , negatives and
  141.          a default of 0.  Leave the box a blank. *)
  142.  
  143.       flt_Box1.Init( TP , 5 , 2 , True , 0 )
  144.  
  145.   End;
  146.  
  147.                           ╔══════════════════╗
  148.                           ║  TLinked_Dialog  ║
  149.                           ╚══════════════════╝
  150.  
  151.  
  152. TLinked_Dialog is descendant of TDialog with improved cursor movement between
  153. fields.
  154.  
  155. Developing for a non-mouse system ( even a mouse system ) where your dialogs
  156. have over about 10 fields gets a bit ugly.  The tab key becomes impracticle
  157. and setting hotkeys for each field may not be practicle.
  158.  
  159. The program EXAMPLE.PAS is not an exageration, it is a SIMPLIFIED version of
  160. a dialog I am developing at work.  Try getting to a field #54 via tabs!
  161.  
  162. TLinked_Dialog solves the problem by having the Dialog jump between links
  163. you define. Cursor keys are used to select the link direction, though 2 spare
  164. links are defined for object future use or for object use.
  165.  
  166.      Example of a linking:               11
  167.                                          21 22
  168.                                          31
  169.  
  170.   Object 21 would want links defined for 11 ( DLink_Up ), 22 ( DLink_Right ),
  171.   and 31 ( DLink_Down ).
  172.  
  173.   Once the links are defined, HandleEvent switches the focus according to the
  174.   cursor keys.
  175.  
  176.  
  177. INITIALIZATION:
  178.  
  179. TDialog is initialized exactly the same as TDialog.  ( Refer to the Turbo Vision
  180. manual for details. )
  181.  
  182. TLinked_Dialog.Init calls TDialog.Init and the initialized a collection of
  183. links to track item linking.
  184.  
  185. USAGE:
  186.  
  187. Once TLinked_Dialog is initialized, you insert items into the TLinked_Dialog
  188. just as you would a normal dialog.
  189.  
  190. After the items are inserted, you set up links.
  191.  
  192. *****  NOTE:  Do not set up links for an item before it is inserted! *****
  193.  
  194. Links are created by calling TLinked_Dialog.Set_Link with
  195.         Item to set link for    : PView
  196.         Direction of link       : Integer
  197.                                               Use the constants:
  198.                                       DLink_Up, Dlink_Down, DLink_Right,
  199.                                       DLink_Left, DLink_Spare1, Dlink_Spare2
  200.         Pointer to linked item  : Pointer
  201.  
  202. All links are 1 way.  If you wish Button55 <--> Button56, you must define
  203. two links, Button55 right to Button56 and Button56 left to Button55.  This is
  204. because multiple items may be linked to the same item, which would make finding
  205. the reverse link impossible.
  206.  
  207. You can select another object via a link by calling TLinked_Dialog.Select_Link
  208. with the link direction.  The currently selected object's link will be traced
  209. to the next object ( If possible ).
  210.  
  211. Example:
  212.  
  213.   Var TR    : TRect ;
  214.       TP    : TPoint ;
  215.       TLD   : TLinked_Dialog ;
  216.       Butt1 : TPushButton ;
  217.       Box1  : TNum_Box ;
  218.       Box2  : TNum_Box ;
  219.       Box3  : TNum_Box ;
  220.       Box4  : TNum_Box ;
  221.  
  222.   Begin
  223.       TR.Assign( 10 , 1 , 70 , 10 );
  224.       TLD.Init( TR ,'Test Linked Dialog');
  225.  
  226.  
  227.       (* Set up a button and insert it *)
  228.  
  229.       TR.Assign( 5 , 3 , 15 , 5 );
  230.       Butt1.Init(TR,'~P~ush',cmOk,bfDefault));
  231.       TLD.Insert( Butt1 );
  232.  
  233.       (* Set up box1 and insert it *)
  234.       TP.Y := 8 ;
  235.       TP.X := 3 ;
  236.  
  237.       Box1.Init( TP , 3 , 2 , FALSE , 1 );
  238.       TLD.Insert( Box1 );
  239.  
  240.       (* Set up box2 and insert it *)
  241.       TP.X := TP.X + 10 ;
  242.  
  243.       Box2.Init( TP , 3 , 2 , FALSE , 1 );
  244.       TLD.Insert( Box2 );
  245.  
  246.       TP.Y := 9 ;
  247.       TP.X := 3 ;
  248.  
  249.       (* Set up box3 and insert it *)
  250.  
  251.       Box3.Init( TP , 3 , 2 , FALSE , 1 );
  252.       TLD.Insert( Box3 );
  253.  
  254.       TP.X := TP.X + 10 ;
  255.  
  256.       (* Set up box and insert it *)
  257.  
  258.       Box4.Init( TP , 3 , 2 , FALSE , 1 );
  259.       TLD.Insert( Box4 );
  260.  
  261.       (*   Boxes at  [1] [2]  *)
  262.       (*             [3] [4]  *)
  263.  
  264.       (* Link Box1 -> Box2 *)
  265.       TDL.Set_Link( @BOX1 , DLink_Right , @BOX2 );
  266.  
  267.       (* Link Box1 <- Box2 *)
  268.       TDL.Set_Link( @BOX2 , DLink_Left  , @BOX1 );
  269.  
  270.       (* Link Box3 -> Box4 *)
  271.       TDL.Set_Link( @BOX3 , DLink_Right , @BOX4 );
  272.  
  273.       (* Link Box3 <- Box4 *)
  274.       TDL.Set_Link( @BOX4 , DLink_Left  , @BOX3 );
  275.  
  276.       (* Link Box1 -> Box3 *)
  277.       TDL.Set_Link( @BOX1 , DLink_Down  , @BOX3 );
  278.  
  279.       (* Link Box1 <- Box3 *)
  280.       TDL.Set_Link( @BOX3 , DLink_Up    , @BOX1 );
  281.  
  282.       (* Link Box2 -> Box4 *)
  283.       TDL.Set_Link( @BOX2 , DLink_Down  , @BOX4 );
  284.  
  285.       (* Link Box2 <- Box4 *)
  286.       TDL.Set_Link( @BOX4 , DLink_Up    , @BOX2 );
  287.  
  288. End;
  289.  
  290.  
  291.